using System.IO;
using System.Windows;
using System.Windows.Markup;

namespace Client.Common
{
    public static class DynamicStyleProvider
    {
        private static ResourceDictionary _resource;

        private static ResourceDictionary Resource
        {
            get
            {
                if (_resource == null)
                {
                    const string fileName = @"Styles.xaml";
                    if (File.Exists(fileName))
                    {
                        using (var fs = new FileStream(fileName, FileMode.Open))
                        {
                            _resource = (ResourceDictionary) XamlReader.Load(fs);
                        }
                    }
                }
                return _resource;
            }
        }

        public static Style ListItemTextBlockMessageStyle()
        {
            return Resource["ListItemTextBlockMessageStyle"] as Style;
        }

        public static Style ListItemTextBlockErrorStyle()
        {
            return Resource["ListItemTextBlockErrorStyle"] as Style;
        }
    }
}